package Exercise;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class Exercise03 {
    @SuppressWarnings({"all"})
    public static void main(String[] args) {
        Map map = new HashMap();
        map.put("jack",650);
        map.put("tom",1200);
        map.put("smith",2900);
        map.put("jack",2600);
       // map.replace("jack",650,2600);
        System.out.println(map);

        Set key = map.keySet();

        //所有人加薪100
        for (Object o :key) {
            map.put(o,(Integer)map.get(o) + 100);
        }
        System.out.println(map);

        //遍历
        for (Object o :key) {
            System.out.println(o + "_" + map.get(o));
        }

        System.out.println("======entry========");
        Set entrySet = map.entrySet();
        for (Object entry :entrySet) {
            Map.Entry m = (Map.Entry) entry;
            System.out.println(m.getKey() + "_" + m.getValue());
        }
        System.out.println("====迭代器=====");
        Iterator iterator = entrySet.iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            System.out.println(entry.getKey() + "_" + entry.getValue());

        }


    }
}
